// pages/mailexamine/mailexamine.js
const app = getApp();
var ea = require('../../utils/each.js');
var WxParse = require('../../utils/wxParse/wxParse.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgs: app.data.imgurl +"ss1.png",
    imgss: app.data.imgurl +"ss0.png",
    imgsss: app.data.imgurl +"ss2.png",
    aimgs: app.data.imgurl +"aimgsss.png",
    aimgss: app.data.imgurl +"aimgs.png",
    aimgsss: app.data.imgurl +"aimgss.png",

    satae:0, //审核的状态 0 1 2 
    stat:0,//判断团体还是个人  0个人  1 团体
    getmyhuiyuaninfo: app.data.url + 'sheyingjia/Xhuiyuan1/getmyhuiyuaninfo',
    chongxinyouji: app.data.url + 'sheyingjia/Xhuiyuan1/chongxinyouji',
    addtuanduizhanghu: app.data.url + 'sheyingjia/Xhuiyuan1/addtuanduizhanghu',
    shuju:{},
    system:{}
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var user = wx.getStorageSync('user');
    var that = this;
    wx.showLoading({
      title: '加载中',
    })
    ea.request(that.data.getmyhuiyuaninfo, { token: user.token }, function (res) {
      wx.hideLoading();
      var data = res.data;
      console.log(data);
      if (data.code == 200) {
        var shuju = data.data.data;
        var system = data.data.system;
        console.log(data.data.soufei);
        WxParse.wxParse('article', 'html', data.data.soufei.tuandui.jianjie, that, 25);
        WxParse.wxParse('geren', 'html', data.data.soufei.geren.jianjie, that, 25);
        that.setData({system:system});
        console.log(shuju);
        if (shuju.jindu == '邮寄申请表') {
          that.setData({ satae: 0 });
        } else if (shuju.jindu == '驳回'){
          that.setData({ satae: 1});
        } else if (shuju.jindu == '批准'){
          if (shuju.huiyuan=='1'){
            that.setData({ stat:0})
          }else{
            that.setData({ stat: 1})
          }
          that.setData({ satae: 2 });
        }
        that.setData({ shuju: shuju });
      } else {
        wx.showToast({
          title: data.msg,
          icon: 'none'
        })
      }
    })
  },
  //重新邮寄
  zhongxin:function(){
    var shuju = this.data.shuju;
    var that = this;
    var user = wx.getStorageSync('user');
    // wx.showLoading({
    //   title: '提交中',
    // })
    ea.qinqiu(that.data.chongxinyouji,{shuju:shuju,token:user.token},function(data){
      wx.navigateTo({
        url: '/pages/memberexpressmail/memberexpressmail',
      })
    },'提交中')
  },
  //填写团队账号和名称
  tianxies:function(e){
    // console.log(e)
    var type = e.currentTarget.dataset.type;
    var value = e.detail.value;
    var shuju = this.data.shuju;
    shuju[type] = value;
    console.log(shuju);
    this.setData({shuju:shuju});
  },
  //个人缴费
  expressmail:function(){
    wx.navigateTo({
      url: '/pages/topersonalinto/topersonalinto',
    })
  },
  //团体缴费
  tuantijiaofei:function(){
    var shuju = this.data.shuju;
    var user = wx.getStorageSync('user');
    var that = this;
    ea.qinqiu(that.data.addtuanduizhanghu,{shuju:shuju,token:user.token},function(data){
      console.log(data);
      wx.navigateTo({
        url: '/pages/togroupinto/togroupinto',
      })
      
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    // wx.redirectTo({
    //   url:'/pages/member/member'
    // });
    // wx.switchTab({
    //   url: '/pages/index/index',
    // })
    // wx.switchTab({
    //   url: '/pages/index/index',
    // });
    wx.switchTab({
      url: '/pages/index/index',
    })
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.onShow();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})